/**
 * 
 */
package org.jftstool.config;

import java.util.ArrayList;
import java.util.List;

/**
 * @author grupo JFTS
 *
 */
public class DBDocumentExtractorConfig {
	private String classExtractor = null;
	private List<DBConnectionConfig> dbConnections = null;
	private List<DBQueryDocumentConfig> dbQueries = null;
	
	
	public DBDocumentExtractorConfig() {
		dbConnections = new ArrayList<DBConnectionConfig>();
		dbQueries = new ArrayList<DBQueryDocumentConfig>();
	}


	public DBDocumentExtractorConfig(String classExtractor, List<DBConnectionConfig> dbConnections, List<DBQueryDocumentConfig> dbQueries) {
		this.classExtractor = classExtractor;
		this.dbConnections = dbConnections;
		this.dbQueries = dbQueries;
	}


	public List<DBConnectionConfig> getDbConnections() {
		return dbConnections;
	}


	public void setDbConnections(List<DBConnectionConfig> dbConnections) {
		this.dbConnections = dbConnections;
	}


	public List<DBQueryDocumentConfig> getDbQueries() {
		return dbQueries;
	}


	public void setDbQueries(List<DBQueryDocumentConfig> dbQueries) {
		this.dbQueries = dbQueries;
	}
	
	public DBConnectionConfig getDBConnection(String name){
		DBConnectionConfig result = null;
		for (DBConnectionConfig conn : dbConnections){
			if (conn.getArg("name").equalsIgnoreCase(name)){
				result = conn;
				break;
			}
		}
		return result;
	}
	
	public DBQueryDocumentConfig getDBQuery(String name){
		DBQueryDocumentConfig result = null;
		for (DBQueryDocumentConfig query : dbQueries){
			if (query.getDbQueryName().equalsIgnoreCase(name)){
				result = query;
				break;
			}
		}
		return result;
	}


	public String getClassExtractor() {
		return classExtractor;
	}


	public void setClassExtractor(String classExtractor) {
		this.classExtractor = classExtractor;
	}
}